package com.tobeface.wechat.showcase.handler;

import com.tobeface.wechat.message.WeChatMessage;
import com.tobeface.wechat.message.WeChatMessageBuilder;
import com.tobeface.wechat.message.WeChatMessageChannel;
import com.tobeface.wechat.message.annotation.DefaultMessageHandler;
import com.tobeface.wechat.message.handler.TextMessageHandlerSupport;

/**
 * @author loudyn
 */
@DefaultMessageHandler
public class EchoMessageHandler extends TextMessageHandlerSupport {

    @Override
    protected void onTextMessageReceived(WeChatMessageChannel channel,
                                         WeChatMessage message,
                                         String content) {

        WeChatMessage outMessage = WeChatMessageBuilder.replyText(message).content(content).build();
        channel.writeMessage(outMessage);
        channel.flush();
    }
}
